// check integer
owl_byte owl_check_wchar_bin(owl_wchar ch)
{
  if (ch >= OWL_MIN_BIN && ch <= OWL_MAX_BIN)
    return 1;
  return 0;
}

// check encoded
owl_byte owl_check_wchar_enc_bin(owl_byte * src, owl_umax size)
{
  // check params
  if (owl_check_ptr(src, size) == owl_false || owl_check_wchar_bin((owl_wchar) *src) == 0)
    return 0;
  return 1;
}

// get integer
owl_wchar owl_get_wchar_bin(owl_byte * src, owl_umax size)
{
  // check params
  if (owl_check_wchar_enc_bin(src, size) == 0)
    return OWL_INV_BIN;
  return (owl_wchar) *src;
}

// write encoded
owl_byte * owl_write_wchar_enc_bin(owl_wchar ch, owl_byte * dest, owl_umax size)
{
  // check params
  if (owl_check_wchar_bin(ch) == 0 || owl_check_ptr(dest, size) == owl_false)
    return NULL;
  *dest = ch;
  return dest + 1;
}

// print integer
owl_byte owl_print_wchar_bin(owl_wchar ch)
{
  // check params
  if (owl_check_wchar_bin(ch) == 0) {
    printf(OWL_INV_BIN_STR);
    return 0;
  }
  printf("%02llX", ch);
  return 1;
}

// print encoded
owl_byte owl_print_wchar_enc_bin(owl_byte * src, owl_umax size)
{
  // check params
  if (owl_check_wchar_enc_bin(src, size) == 0) {
    printf(OWL_INV_ENC_BIN_STR);
    return 0;
  }
  printf("%02X", *src);
  return 1;
}

// convert an ascii character into an unicode character
owl_wchar owl_wchar_bin_as_unicode(owl_wchar bin)
{
  if (owl_check_wchar_ascii(bin) == 1)
    return bin;
  return OWL_INV_BIN;
}

// convert an unicode character into an ascii character
owl_wchar owl_wchar_unicode_as_bin(owl_wchar unicode)
{
  if (owl_check_wchar_ascii(unicode) == 1)
    return unicode;
  return OWL_INV_UNICODE;
}
